package com.example.steveaoblogdemo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.steveaoblogdemo.entity.Articles;
import com.example.steveaoblogdemo.entity.Category;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
    @Insert("insert into category (id,c_name) values (#{id},#{cName})")
    int addCategory(Integer id,String cName);

    @Update("update category set c_name=#{cName} where id=#{id}")
    int updateCategory(String cName,Integer id);

    @Select("select a.* from articles a,category c where a.category=c.c_name and a.status=0 and c.id=#{id}")
    List<Articles> query(Integer id);

}
